package pl.ydp.components.mathcell.mathcell.utils
{
	public class HybridFocusManager
	{
		private var triggerCounter:Number;
		private var DRAWING_TRIGGER:Number = 3;
		private var isHybridMode:Boolean; 
		
		/**
		 * This class handles the hybrid focus of the cell.
		 * 
		 * The point of the hybrid focus are (1) 'focus by click' and 
		 * (2) 'drawing on focus'.
		 * 
		 * (1) means that the focus is set to cell when the cell is 
		 * clicked.
		 * 
		 * (2) means that user can directly draw to a cell that has 
		 * previously been not focused if the input activity is longer
		 * than a single click.
		 * 
		 *  It means that: If the cell is not focuse and user only clicks
		 * nothing is drawn and the cell receives focus.
		 * If the cell is not focused and user draws a longer shape
		 * the cell receives focus and the shape is accepted as the input.
		 */
		public function HybridFocusManager()
		{
		}

		public function startDrawing(focused:Boolean):void{
			triggerCounter = 0;
			isHybridMode = !focused;
		}
		
		public function processDrawing():void{
			triggerCounter++;
		}
		
		public function stopDrawing():void{
			
		}
		
		public function drawingEnabled():Boolean{
			return !isHybridMode  ||  triggerCounter > DRAWING_TRIGGER;
		} 

	}
}